﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Services
{
	/// <summary>
	/// cookie
	/// </summary>
	public class Cookie
	{

		private static string CookieName = bonus.Models.WebConfig.USERCOOKIE;

		/// <summary>
		/// 获取cookie 手机号
		/// </summary>
		/// <returns></returns>
		public static string GetMobile()
		{
			HttpCookie cookie = cookie = new HttpCookie("temp");

			HttpCookie _cookie = HttpContext.Current.Request.Cookies[CookieName];

			string temp = "";

			if (_cookie == null)
			{
				temp = "";
			}
			else
			{
				_cookie.Value = HttpUtility.UrlDecode(_cookie.Value);
				cookie.Value = _cookie.Value;
				temp = cookie["Mobile"];
				if (string.IsNullOrEmpty(temp))
				{
					temp = "";
				}
			}
			return temp;

		}

		/// <summary>
		/// 获取cookie id
		/// </summary>
		/// <returns></returns>
		public static string GetId()
		{
			HttpCookie cookie = cookie = new HttpCookie("temp");

			HttpCookie _cookie = HttpContext.Current.Request.Cookies[CookieName];

			string temp = "";

			if (_cookie == null)
			{
				temp = "";
			}
			else
			{
				_cookie.Value = HttpUtility.UrlDecode(_cookie.Value);
				cookie.Value = _cookie.Value;
				temp = cookie["UserId"];
				if (string.IsNullOrEmpty(temp))
				{
					temp = "";
				}
			}
			return temp;
		}

		/// <summary>
		/// 获取cookie 用户名
		/// </summary>
		/// <returns></returns>
		public static string GetUserName()
		{
			HttpCookie cookie = cookie = new HttpCookie("temp");

			HttpCookie _cookie = HttpContext.Current.Request.Cookies[CookieName];

			string temp = "";

			if (_cookie == null)
			{
				temp = "";
			}
			else
			{
				_cookie.Value = HttpUtility.UrlDecode(_cookie.Value);
				cookie.Value = _cookie.Value;
				temp = HttpUtility.UrlDecode(cookie["UserName"]);
				if (string.IsNullOrEmpty(temp))
				{
					temp = "";
				}
			}
			return temp;
		}


		/// <summary>
		/// 获取用户编号
		/// </summary>
		/// <param name="cookieName"></param>
		/// <returns></returns>
		public static string GetUserNo()
		{
			HttpCookie cookie = cookie = new HttpCookie("temp");

			HttpCookie _cookie = HttpContext.Current.Request.Cookies[CookieName];

			string temp = "";

			if (_cookie == null)
			{
				temp = "";
			}
			else
			{
				_cookie.Value = HttpUtility.UrlDecode(_cookie.Value);
				cookie.Value = _cookie.Value;
				temp = HttpUtility.UrlDecode(cookie["NO"]);
				if (string.IsNullOrEmpty(temp))
				{
					temp = "";
				}
			}
			return temp;
		}

		/// <summary>
		/// 获取用户类型
		/// </summary>
		/// <param name="cookieName"></param>
		/// <returns></returns>
		public static string GetUserType()
		{
			HttpCookie cookie = cookie = new HttpCookie("temp");

			HttpCookie _cookie = HttpContext.Current.Request.Cookies[CookieName];

			string temp = "";

			if (_cookie == null)
			{
				temp = "";
			}
			else
			{
				_cookie.Value = HttpUtility.UrlDecode(_cookie.Value);
				cookie.Value = _cookie.Value;
				temp = HttpUtility.UrlDecode(cookie["Type"]);
				if (string.IsNullOrEmpty(temp))
				{
					temp = "";
				}
			}
			return temp;
		}

		/// <summary>
		/// 获取状态码
		/// </summary>
		/// <param name="cookieName"></param>
		/// <returns></returns>
		public static string GetMsgCode()
		{
			HttpCookie cookie = cookie = new HttpCookie("temp");

			HttpCookie _cookie = HttpContext.Current.Request.Cookies[bonus.Models.WebConfig.MSGCOOKIE];

			string temp = "";

			if (_cookie == null)
			{
				temp = "";
			}
			else
			{
				_cookie.Value = HttpUtility.UrlDecode(_cookie.Value);
				cookie.Value = _cookie.Value;
				temp = HttpUtility.UrlDecode(cookie["Code"]);
				if (string.IsNullOrEmpty(temp))
				{
					temp = "";
				}
			}
			return temp;
		}

		/// <summary>
		/// 获取账户申请数量
		/// </summary>
		/// <param name="cookieName"></param>
		/// <returns></returns>
		public static string GetMsgAccount()
		{
			HttpCookie cookie = cookie = new HttpCookie("temp");

			HttpCookie _cookie = HttpContext.Current.Request.Cookies[bonus.Models.WebConfig.MSGCOOKIE];

			string temp = "";

			if (_cookie == null)
			{
				temp = "";
			}
			else
			{
				_cookie.Value = HttpUtility.UrlDecode(_cookie.Value);
				cookie.Value = _cookie.Value;
				temp = HttpUtility.UrlDecode(cookie["Account"]);
				if (string.IsNullOrEmpty(temp))
				{
					temp = "";
				}
			}
			return temp;
		}


		/// <summary>
		/// 获取踢歘没申请数量
		/// </summary>
		/// <param name="cookieName"></param>
		/// <returns></returns>
		public static string GetMsgWithdraw()
		{
			HttpCookie cookie = cookie = new HttpCookie("temp");

			HttpCookie _cookie = HttpContext.Current.Request.Cookies[bonus.Models.WebConfig.MSGCOOKIE];

			string temp = "";

			if (_cookie == null)
			{
				temp = "";
			}
			else
			{
				_cookie.Value = HttpUtility.UrlDecode(_cookie.Value);
				cookie.Value = _cookie.Value;
				temp = HttpUtility.UrlDecode(cookie["Withdraw"]);
				if (string.IsNullOrEmpty(temp))
				{
					temp = "";
				}
			}
			return temp;
		}

	}
}